class Stack {
  constructor() {
    this.nodes = [];
  }

  push(value) {
    this.nodes.push(value);
  }

  pop() {
    return this.nodes.pop();
  }

  isEmpty() {
    return this.nodes.length === 0;
  }

  toArray() {
    return this.nodes.slice();
  }
}

const stack = new Stack();

stack.push(1);
stack.push(2);
console.log(stack.toArray());

console.log(stack.pop());
console.log(stack.toArray());
